package com.ruoyi.web.controller.system;

import java.util.List;

import com.ruoyi.common.core.domain.entity.BusinessSysUnit;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.IBusinessSysUnitService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 业务系统-1Controller
 * 
 * @author ess
 * @date 2021-10-18
 */
@RestController
@RequestMapping("/system/businUnit")
public class BusinessSysUnitController extends BaseController
{
    @Autowired
    private IBusinessSysUnitService businessSysUnitService;

    /**
     * 查询业务系统-1列表
     */
    @PreAuthorize("@ss.hasPermi('system:businUnit:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusinessSysUnit businessSysUnit)
    {
        startPage();
        List<BusinessSysUnit> list = businessSysUnitService.selectBusinessSysUnitList(businessSysUnit);
        return getDataTable(list);
    }

    /**
     * 导出业务系统-1列表
     */
    @PreAuthorize("@ss.hasPermi('system:businUnit:export')")
    @Log(title = "业务系统-1", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BusinessSysUnit businessSysUnit)
    {
        List<BusinessSysUnit> list = businessSysUnitService.selectBusinessSysUnitList(businessSysUnit);
        ExcelUtil<BusinessSysUnit> util = new ExcelUtil<BusinessSysUnit>(BusinessSysUnit.class);
        return util.exportExcel(list, "业务系统-1数据");
    }

    /**
     * 获取业务系统-1详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:businUnit:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(businessSysUnitService.selectBusinessSysUnitById(id));
    }

    /**
     * 新增业务系统-1
     */
    @PreAuthorize("@ss.hasPermi('system:businUnit:add')")
    @Log(title = "业务系统-1", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusinessSysUnit businessSysUnit)
    {
        return toAjax(businessSysUnitService.insertBusinessSysUnit(businessSysUnit));
    }

    /**
     * 修改业务系统-1
     */
    @PreAuthorize("@ss.hasPermi('system:businUnit:edit')")
    @Log(title = "业务系统-1", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusinessSysUnit businessSysUnit)
    {
        return toAjax(businessSysUnitService.updateBusinessSysUnit(businessSysUnit));
    }

    /**
     * 删除业务系统-1
     */
    @PreAuthorize("@ss.hasPermi('system:businUnit:remove')")
    @Log(title = "业务系统-1", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(businessSysUnitService.deleteBusinessSysUnitByIds(ids));
    }
}
